package counter

import (
	"github.com/crack007/fpm_metrics/src/constant"
	"github.com/prometheus/client_golang/prometheus"
)

var List = map[string]prometheus.Gauge{}

func NewGauge(name string) prometheus.Gauge {
	return prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace:   "stat",
		Subsystem:   "fpm",
		Name:        name,
		Help:        "",
		ConstLabels: nil,
	})
}

func Register() {
	List[constant.START_SINCE] = NewGauge(constant.START_SINCE)
	List[constant.ACCEPTED_CONN] = NewGauge(constant.ACCEPTED_CONN)
	List[constant.LISTEN_QUEUE] = NewGauge(constant.LISTEN_QUEUE)
	List[constant.MAX_LISTEN_QUEUE] = NewGauge(constant.MAX_LISTEN_QUEUE)
	List[constant.LISTEN_QUEUE_LEN] = NewGauge(constant.LISTEN_QUEUE_LEN)
	List[constant.IDLE_PROCESSES] = NewGauge(constant.IDLE_PROCESSES)
	List[constant.ACTIVE_PROCESSES] = NewGauge(constant.ACTIVE_PROCESSES)
	List[constant.TOTAL_PROCESSES] = NewGauge(constant.TOTAL_PROCESSES)
	List[constant.MAX_ACTIVE_PROCESSES] = NewGauge(constant.MAX_ACTIVE_PROCESSES)
	List[constant.MAX_CHILDREN_REACHED] = NewGauge(constant.MAX_CHILDREN_REACHED)
	List[constant.SLOW_REQUESTS] = NewGauge(constant.SLOW_REQUESTS)
}
func GetCounter(name string) prometheus.Gauge {
	if v, ok := List[name]; ok {
		return v
	}
	return nil
}
